/*
 * tsched_example.cpp
 *
 *  Created on: Oct 18, 2012
 *      Author: tiberius
 */

#include "thread_scheduler.h"

using namespace std;

struct main_module {
	void thread1() {
		cout<<"Hello from thread1"<<endl;
		cout.flush();
//		sleep(1);
	}
	void thread2() {
			cout<<"Hello from thread2"<<endl;
			cout.flush();
//			sleep(1);
	}

	typedef thread_handle<main_module> th_t;
	void run() {
		th_t* th1 = new th_t(this,&main_module::thread1);
		th_t* th2 = new th_t(this,&main_module::thread2);
//		cout<<"Starting threads..."<<endl;
//		th1->start();
//		th2->start();
		cout<<"Joining threads..."<<endl;
		th1->join();
		th_t* th3 = new th_t(this,&main_module::thread1);
		th2->join();
		th3->join();
	}
};

int main() {
	main_module mm_inst;
	mm_inst.run();
	//pthread_exit(NULL);
	return 0;
}


